package cn.sh.cares.tools.srcgen.db;

import java.util.ArrayList;
import java.util.List;


public class TableDefinition {

    private String catalog;
    
    private String schema;
    
    private String tableName;
    
    private String description;
    
    private String javaClass;

    private ColumnDefinitions columnDefinitions = new ColumnDefinitions();
    
    public TableDefinition(String catalog, String schema, String tableName) {
    	this.catalog = catalog;
    	this.schema = schema;
    	this.tableName = tableName;
    }
    
	public ColumnDefinitions getColumnDefinitions() {
		return columnDefinitions;
	}

	public void setColumnDefinitions(ColumnDefinitions columnDefinitions) {
		this.columnDefinitions = columnDefinitions;
	}

	public String getTableName() {
		return tableName;
	}

	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getJavaClass() {
		return javaClass;
	}

	public void setJavaClass(String javaClass) {
		this.javaClass = javaClass;
	}

	public String getCatalog() {
		return catalog;
	}

	public void setCatalog(String catalog) {
		this.catalog = catalog;
	}

	public String getSchema() {
		return schema;
	}

	public void setSchema(String schema) {
		this.schema = schema;
	}
    
    public List<String> getImportClasses() {
    	List<String> importClasses = new ArrayList<String>();
    	for (ColumnDefinition cd : columnDefinitions.getBaseColumns()) {
    		if (cd.getJavaTypeResolver().isExplicitlyImported()) {
    			if (!importClasses.contains(cd.getJavaTypeResolver().getFullyQualifiedName())) {
    				importClasses.add(cd.getJavaTypeResolver().getFullyQualifiedName());
    			}
    		}
    	}
    	return importClasses;
    }
}
